#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+10,R = 2.5e4;
vector<int> bian[N];
int mdep[N];
bool marked[N];
void dfs(int x,int fa){
    mdep[x] = 1;
    for(int v: bian[x]){
        dfs(v,x);
        mdep[x] = max(mdep[v] + 1,mdep[x]);
    }
    if(mdep[x] > mdp || x == 1){
        mdep[x] = 0;
        marked[x] = 1;
    }
}
int h[N],fath[N];
void merge(vector<int> &v1,vector<int> &v2){
    if(v1.size() < v2.size()){
        swap(v1,v2);
    }
    for(int v: v2){
        v1.push_back(v);
    }
    v2.clear();
}
vector<int> bian1[N];
vector<int> mark(int x,int fa){
    vector<int> S;
    for(int v : bian[x]){
        if(v == fa){
            continue;
        }
        vector<int> cs = mark(v,x);
        merge(S,cs);
    }
    if(marked[x]){
        bian1[x].swap(cs);
        cs.push_back(x);
    }
    return cs;
}
unordered_map<long long,int>
int main(){
    int n,r,q;
    cin>>n>>r>>q;
    cin>>h[1];
    for(int i = 2;i<=n;i++){
        cin>>fath[i]>>h[i];
        bian[fath[i]].push_back(i);
    }

}